﻿@{
  string dataTitle = ViewBag.IsDraft ? "DraftDetail" : "MailDetail";
  string baseUrl = VirtualPathUtility.ToAbsolute(ViewBag.IsDraft ? "~/Mail/Editor" : "~/Mail/Reader");
}
<table id="mail-list" class="table table-striped table-advance table-hover">
	<colgroup>
		<col width="35px">
		<col width="300px">
		<col>
		<col width="150px">
	</colgroup>
	<thead>
	<tr>
		<th colspan="2">
			<input type="checkbox" class="mail-checkbox mail-group-checkbox" data-set="#mail-list .mail-checkbox" />
			<div class="btn-group">
				<a class="btn btn-sm blue dropdown-toggle" href="javascript:;" data-toggle="dropdown" aria-expanded="false">
				操作 <i class="fa fa-angle-down"></i>
				</a>
				<ul class="dropdown-menu">
                    @if(ViewBag.IsInbox){
					<li>
						<a href="~/Mail/MarkRead?read=true" data-type="MarkRead">
						<i class="fa fa-pencil"></i> 标记为已读 </a>
					</li>
					<li>
						<a href="~/Mail/MarkRead?read=false" data-type="MarkRead">
						<i class="fa fa-ban"></i> 标记为未读 </a>
					</li>
					<li class="divider">
					</li>
                    }
                    @if(!ViewBag.IsTrash){
					<li>
						<a href="~/Mail/MarkDelete" data-type="MarkDelete">
						<i class="fa fa-trash-o"></i> 删除 </a>
					</li>
                    }else{
					<li>
						<a href="~/Mail/Restore" data-type="Restore">
						<i class="fa fa-history"></i> 恢复 </a>
					</li>
					<li>
						<a href="~/Mail/Delete" data-type="Delete">
						<i class="fa fa-trash-o"></i> 永久删除 </a>
					</li>
                    }
				</ul>
			</div>
		</th>
		<th class="pagination-control" colspan="2">
			<span class="pagination-info">@ViewBag.NavText</span>
			@Html.Raw(ViewBag.Nav)
		</th>
	</tr>
	</thead>
	<tbody>
    @foreach(TBM.Models.MailItem item in ViewBag.Mails){
    <tr @Html.Raw(item.MarkRead ? "" : "class=\"unread\"") data-target="@("#" + TBM.Core.App.ToBase64("action=" + baseUrl + "&mid=" + item.ID))" data-type="@dataTitle">
      <td class="inbox-small-cells">
        <input name="mid" type="checkbox" class="mail-checkbox" value="@item.ID" />
		  </td>
      <td class="view-message hidden-xs">@item.MailTo</td>
      <td class="view-message">@item.Subject</td>
      <td class="view-message text-right">@item.CreateDate.ToString("yyyy-MM-dd hh:mm")</td>
    </tr>
    }
  </tbody>
</table>